/**
 * Created by ShaunJ on 16/12/12.
 */
angular.module(moduleName + '.services')
    .service('CommonDaterService', function () {


        this.init = function(startdate,enddate,hourstart,hourend){
            //设置起始和终止日期
            if(!startdate){
                startdate ='1970-01-01';
            }
            if(!enddate){
                enddate ='2022-12-31';
            }

            var initStartYear = Number(new Date(startdate).getFullYear());//起始年
            var initEndYear = Number(new Date(enddate).getFullYear());//终止年
            var yearArr = [],
                monthArr = [],
                dateArr = [],
                hourArr = [],
                minArr = [];
            for (var i = 0 ; i < (initEndYear-initStartYear+1) ; i++) {
                yearArr.push(initStartYear+i)
            }
            for (var loop = 0 ; loop < 10 ; loop++) {
                for (var j = 1; j <= 12; j++) {
                    var tempMonth = '';
                    if (j < 10) {
                        tempMonth = '0' + j;
                    } else {
                        tempMonth = j + ''
                    }
                    monthArr.push(tempMonth)
                }

                for (var m = 0; m < 24; m++) {
                    var tempHour = '';
                    if (m < 10) {
                        tempHour = '0' + m;
                    } else {
                        tempHour = m;
                    }
                    hourArr.push(tempHour);
                }
                for (var n = 0; n < 60; n++) {
                    var tempMin = '';
                    if (n < 10) {
                        tempMin = '0' + n;
                    } else {
                        tempMin = n;
                    }
                    minArr.push(tempMin);
                }
            }

            this.yearArr = yearArr;
            this.monthArr = monthArr;
            this.dateArr = dateArr;
            this.minArr = minArr;
            this.hourArr = hourArr
        }
    });
